import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import refresh from '@dfeidao/atom-web/url/refresh';
import get from '@dfeidao/atom-web/local/get';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// 编辑保存
	const nos = get(fd, 'nos');
	const sub = fd.data.node.querySelector<HTMLTextAreaElement>('[data-id="name"]').value;
	if (!sub) {
		alert('请将信息填写完整');
		return;
	}
	//风险等级
	const level = fd.data.node.querySelector<HTMLSelectElement>('[data-id="optional_value"]').value;
	if (level === "请选择风险等级") {
		alert('请将信息填写完整');
		return;
	}
	const r = await nodejs<{ code: 0 | 1; }>('risk-point/zj-000010/s001', {
		filter: {
			risk_po_type_no: nos,
			risk_po_type_name: sub,
			risk_level: level
		}
	});
	console.log(r);
	if (r.code === 1) {
		const n = fd.data.node.querySelector<HTMLDivElement>('[data-id="edit"]');
		set_node_cls(n, 'display-n', true);
		alert("修改成功");
		refresh();
	} else {
		alert("修改失败");
	}
}
